﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FastPoster.MainForms
{
    #region using
    using DevComponents.DotNetBar;
    using FastPoster.DataProviders.BUS;
    using FastPoster.DataProviders.DTO;
    using FastPoster.Helpers;
    #endregion

    public partial class FrmNhapTaiKhoan : Office2007Form
    {
        //  event handler to transfer data to other forms
        public EventHandler Handler { get; set; }

        public FrmNhapTaiKhoan()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtTenDangNhap.Text.Trim() == string.Empty)
            {
                MessageBoxEx.Show("Vui lòng nhập tên đăng nhập", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtMatKhau.Text.Trim() == string.Empty)
            {
                MessageBoxEx.Show("Vui lòng nhập mật khẩu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TransferDataInfo(this, new TransferDataEvent(txtTenDangNhap.Text + "#" + txtMatKhau.Text));
        }

        /// <summary>
        ///  function is used to transfer data when event would be raised
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void TransferDataInfo(object sender, TransferDataEvent e)
        {
            this.Handler(this, e);
            this.Close();
        }
    }
}
